<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/WEB-TAG/platForm.tld" prefix="PF"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<PF:basePath/>">
		<title>包信息</title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<jsp:include page="/WEB-FACE/conf/includeH.jsp"></jsp:include>
	</head>
	<body class="easyui-layout">
		<div
			data-options="region:'east',iconCls:'icon-attibutes',title:'模板',split:true"
			style="width: 500px;">
			<table id="dom_datagridfarmcodetemplet">
				<thead>
					<tr>
						<th data-options="field:'ck',checkbox:true"></th>
						<th field="TEMNAME" data-options="sortable:true" width="80">
							模板名称
						</th>
						<th field="FILENAME" data-options="sortable:true" width="80">
							文件名称
						</th>
					</tr>
				</thead>
			</table>
		</div>
		<div data-options="region:'center',border:false">
			<table id="dom_datagridfarmcodepackage">
				<thead>
					<tr>
						<th data-options="field:'ck',checkbox:true"></th>
						<th field="PACKNAME" data-options="sortable:true" width="60">
							包中文名
						</th>
						<th field="PACKCODE" data-options="sortable:true" width="80">
							包CODE
						</th>
					</tr>
				</thead>
			</table>
		</div>
	</body>
	<script type="text/javascript">
	var url_delActionfarmcodepackage = "admin/FarmCodePackagedeleteCommit.do";//删除URL
	var url_formActionfarmcodepackage = "admin/FarmCodePackageshow.do";//增加、修改、查看URL
	var url_searchActionfarmcodepackage = "admin/FarmCodePackagequeryAll.do?projectId=${ids}";//查询URL
	var title_windowfarmcodepackage = "包信息";//功能名称
	var gridfarmcodepackage;//数据表格对象
	var searchfarmcodepackage;//条件查询组件对象
	var url_delActionfarmcodetemplet = "admin/FarmCodeTempletdeleteCommit.do";//删除URL
	var url_formActionfarmcodetemplet = "admin/FarmCodeTempletshow.do";//增加、修改、查看URL
	var url_searchActionfarmcodetemplet = "admin/FarmCodeTempletqueryAll.do";//查询URL
	var title_windowfarmcodetemplet = "模板信息";//功能名称
	var gridfarmcodetemplet;//数据表格对象
	var searchfarmcodetemplet;//条件查询组件对象
	var packId;
	var TOOL_BARfarmcodepackage = [ {
		id : 'add',
		text : '新增',
		iconCls : 'icon-add',
		handler : addDatafarmcodepackage
	}, {
		id : 'edit',
		text : '修改',
		iconCls : 'icon-edit',
		handler : editDatafarmcodepackage
	}, {
		id : 'del',
		text : '删除',
		iconCls : 'icon-remove',
		handler : delDatafarmcodepackage
	}, {
		id : 'importPack',
		text : '复制导入',
		iconCls : 'icon-move_to_folder',
		handler : importDatafarmcodepackage
	} ];
	var TOOL_BARfarmcodetemplet = [ {
		id : 'add',
		text : '新增',
		iconCls : 'icon-add',
		handler : addDatafarmcodetemplet
	}, {
		id : 'edit',
		text : '复制导入',
		iconCls : 'icon-move_to_folder',
		handler : importDatafarmcodetemplet
	}, {
		id : 'edit',
		text : '修改',
		iconCls : 'icon-edit',
		handler : editDatafarmcodetemplet
	}, {
		id : 'del',
		text : '删除',
		iconCls : 'icon-remove',
		handler : delDatafarmcodetemplet
	} ];
	$(function() {
		//初始化数据表格
		gridfarmcodepackage = $('#dom_datagridfarmcodepackage').datagrid( {
			url : url_searchActionfarmcodepackage,
			fit : true,
			fitColumns : true,
			'toolbar' : TOOL_BARfarmcodepackage,
			pagination : true,
			closable : true,
			checkOnSelect : true,
			striped : true,
			rownumbers : true,
			ctrlSelect : true,
			onClickRow : function(rowIndex, rowData) {
				packId = rowData.ID;
				$(gridfarmcodetemplet).datagrid('load', {
					packid : rowData.ID
				});
			}

		});
		//初始化数据表格
		gridfarmcodetemplet = $('#dom_datagridfarmcodetemplet').datagrid( {
			url : url_searchActionfarmcodetemplet,
			fit : true,
			fitColumns : true,
			'toolbar' : TOOL_BARfarmcodetemplet,
			pagination : true,
			closable : true,
			checkOnSelect : true,
			striped : true,
			rownumbers : true,
			ctrlSelect : true
		});

	});
	//新增
	function addDatafarmcodepackage() {
		var url = url_formActionfarmcodepackage
				+ '?projectId=${ids}&pageset.pageType=' + PAGETYPE.ADD;
		$.farm.openWindow( {
			id : 'winfarmcodepackage',
			width : 600,
			height : 300,
			modal : true,
			url : url,
			title : '新增'
		});
	}
	//修改
	function editDatafarmcodepackage() {
		var selectedArray = $(gridfarmcodepackage).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionfarmcodepackage + '?pageset.pageType='
					+ PAGETYPE.EDIT + '&ids=' + selectedArray[0].ID;
			;
			$.farm.openWindow( {
				id : 'winfarmcodepackage',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '修改'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}
	//删除
	function delDatafarmcodepackage() {
		var selectedArray = $(gridfarmcodepackage).datagrid('getSelections');
		if (selectedArray.length > 0) {
			// 有数据执行操作
			var str = selectedArray.length + MESSAGE_PLAT.SUCCESS_DEL_NEXT_IS;
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$(gridfarmcodepackage).datagrid('loading');
					$.post(url_delActionfarmcodepackage + '?ids='
							+ $.farm.getCheckedIds(gridfarmcodepackage), {},
							function(flag) {
								$(gridfarmcodepackage).datagrid('loaded');
								if (flag.pageset.commitType == 0) {
									$(gridfarmcodepackage).datagrid('reload');
									$(gridfarmcodetemplet).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ flag.pageset.message;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
	
	//复制导入包
	function importDatafarmcodepackage() {
		chooseWindowCallBackHandle = function(row) {
			var idsStr = null;
			$(row).each(function(i, obj) {
				if (idsStr) {
					idsStr=idsStr+','+obj.ID;
				} else {
					idsStr=obj.ID;
				}
			});
			//询问窗口
			$.messager.confirm(MESSAGE_PLAT.PROMPT, "是否导入选中包？", function(flag) {
				if (flag) {
					$(gridfarmcodepackage).datagrid('loading');
					$.post("admin/CopypackageCommit.do", {
						ids : idsStr,
						projectId : '${ids}'
					}, function(flag) {
						if (flag.pageset.commitType == 0) {
							$(gridfarmcodepackage).datagrid('loaded');
							$(gridfarmcodepackage).datagrid('reload');
							$('#chooseImportpackage40468Win').window('close');
						} else {
							var str = MESSAGE_PLAT.ERROR_SUBMIT
									+ flag.pageset.message;
							$.messager.alert(MESSAGE_PLAT.ERROR, str, 'error');
						}
					});
				}
			});

		};
		$.farm.openWindow( {
			id : 'chooseImportpackage40468Win',
			width : 600,
			height : 300,
			modal : true,
			url : 'admin/Importpackage40468ChooseGridPage.do',
			title : '导入工程包'
		});
	}
	//复制导入模板
	function importDatafarmcodetemplet() {
		if (!packId) {
			$.messager
					.alert(MESSAGE_PLAT.PROMPT, "请先选择一条包记录，为其增加模板文件！", 'info');
			return;
		}
		chooseWindowCallBackHandle = function(row) {
			if (row) {
				$.post("admin/FarmCodeTempletCopyCommit.do" + '?ids='
						+ row[0].ID, {
					packid : packId
				}, function(flag) {
					if (flag.pageset.commitType == 0) {
						$(gridfarmcodetemplet).datagrid('reload');
					} else {
						var str = MESSAGE_PLAT.ERROR_SUBMIT
								+ flag.pageset.message;
						$.messager.alert(MESSAGE_PLAT.ERROR, str, 'error');
					}
				});
				$('#chooseWinfarmcodetemplet').window('close');
			}
		};
		$.farm.openWindow( {
			id : 'chooseWinfarmcodetemplet',
			width : 600,
			height : 300,
			modal : true,
			url : 'admin/FarmCodeTemplet_ACTION_ALERT.do',
			title : "复制模板"
		});
	}

	//新增模板
	function addDatafarmcodetemplet() {
		if (!packId) {
			$.messager
					.alert(MESSAGE_PLAT.PROMPT, "请先选择一条包记录，为其增加模板文件！", 'info');
			return;
		}
		var url = url_formActionfarmcodetemplet + '?packid=' + packId
				+ '&pageset.pageType=' + PAGETYPE.ADD;
		$.farm.openWindow( {
			id : 'winfarmcodetemplet',
			width : 600,
			height : 300,
			modal : true,
			url : url,
			title : '新增'
		});
	}
	//修改模板
	function editDatafarmcodetemplet() {
		var selectedArray = $(gridfarmcodetemplet).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionfarmcodetemplet + '?pageset.pageType='
					+ PAGETYPE.EDIT + '&ids=' + selectedArray[0].ID;
			;
			$.farm.openWindow( {
				id : 'winfarmcodetemplet',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '修改'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}
	//删除模板
	function delDatafarmcodetemplet() {
		var selectedArray = $(gridfarmcodetemplet).datagrid('getSelections');
		if (selectedArray.length > 0) {
			// 有数据执行操作
			var str = selectedArray.length + MESSAGE_PLAT.SUCCESS_DEL_NEXT_IS;
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$(gridfarmcodetemplet).datagrid('loading');
					$.post(url_delActionfarmcodetemplet + '?ids='
							+ $.farm.getCheckedIds(gridfarmcodetemplet), {},
							function(flag) {
								$(gridfarmcodetemplet).datagrid('loaded');
								if (flag.pageset.commitType == 0) {
									$(gridfarmcodetemplet).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ flag.pageset.message;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
</script>
</html>




